<?php
/**
 * Object Relational Persistence Mapping Class for table: odonto_stomatology_encounter
 *
 * @package	com.athena
 * @author	LHV
 */
class EmrCanLamSang extends ORDataObject {

	/**#@+
     * Fields of table: emr_general_examination_2 mapped to class members
     */
    var $emr_can_lam_sang_id       = '';
    var $medical_record_id      = '';
    var $sieu_am     = '';
    var $xet_nghiem        = '';
    var $x_quang     = '';
    var $ghi_chu    = '';
    var $encounter_date     = '';
    
    /**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'emr_can_lam_sang';

	/**
	 * Primary Key
	 */
	var $_key = 'emr_can_lam_sang_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'EmrCanLamSang';

	/**
	 * Handle instantiation
	 */
	function EmrCanLamSang() {
		parent::ORDataObject();
	}	
	
   /**
     * Overwrite persit to write datetime value
     * @see celini/ordo/ORDataObject#persist()
     */
    public function persist() {               
        parent::persist();                      
        $sql = "UPDATE $this->_table SET encounter_date = NOW() WHERE $this->_key = " . $this->get_id();
        $this->_execute($sql);
        
        return true;
    }
	
	public function getObjectFromRecordId($recordId) {		
		$sql = "SELECT $this->_key FROM $this->_table WHERE medical_record_id = $recordId";
		$res = $this->_execute($sql);
		
		$id = (!$res->EOF) ? $res->fields[$this->_key] : '';		
		return Celini::newORDO($this->_internalName, $id);
	}					
}
?>
